﻿
using Maticsoft.BLL;
using Maticsoft.Model;

using System;
using System.Web.UI.HtmlControls;
using Utils;

public partial class WebPage_Youhui_XinjianDaijin : SystemBBasePage
{

    protected string time;


    protected override void OnLoad(EventArgs e)
    {
        base.OnLoad(e);
        this.HeaderControl1.Select = "youhuiquan";
        if (!base.IsPostBack)
        {
            this.time = DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString() + "_AS";
        }
        if ((base.Request.Form["commit"] != null) && (base.Request.Form["partner_id"] != null))
        {
            int num = int.Parse(base.Request.Form["quantity"].ToString());
            try
            {
                if (num <= 0x3e8)
                {
                    Maticsoft.Model.Card model = new Maticsoft.Model.Card();
                    Maticsoft.BLL.Card card2 = new Maticsoft.BLL.Card();
                    for (int i = 0; i < num; i++)
                    {
                        model.Partner_id = int.Parse(base.Request.Form["partner_id"].ToString());
                        model.Credit = int.Parse(base.Request.Form["money"].ToString());
                        model.Begin_time = Convert.ToDateTime(base.Request.Form["begin_time"].ToString());
                        model.End_time = Convert.ToDateTime(base.Request.Form["end_time"].ToString());
                        model.Code = base.Request.Form["code"].ToString();
                        model.Order_id = 0;
                        model.Id = Helper.GetRandomString(0x10);
                        model.Team_id = 0;
                        model.consume = "N";
                        card2.Add(model);
                    }
                    base.SetSuccess(num + "张代金券生成成功");
                }
                else
                {
                    this.SetError("代金券每次只能生产1-1000枚");
                }
            }
            catch (Exception)
            {
                this.SetError("您输入的日期格式不正确");
            }
        }
    }
}

